import { api } from '../boot/axios'
import { StockItem, Version } from './type'

function url(s: string) {
  if (s==''){
    return ['/api/upload', ''].join('/')
  }
  return ['/api/upload', s.replace('/', ''), ''].join('/')
}

export function importStockMaster(data: { file:File }) {
  const formData = new FormData()
  formData.append('file',data.file)
  return api({
    headers: {'Content-Type': 'multipart/form-data;'},
    url: url('import_stock_item_master'),
    method: 'POST',
    data:formData
  });
}


export function importPartsMaster(data: { file:File }) {
  const formData = new FormData()
  formData.append('file',data.file)
  return api({
    headers: {'Content-Type': 'multipart/form-data;'},
    url: url('import_parts_master'),
    method: 'POST',
    data:formData
  });
}